package com.saikei.statstitlebar;



/*
 * File: BarTextView.java
 * Author: gewu
 * Create: 2022/10/27 19:53
 * Changes:
 */
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;

public class BarTextView extends androidx.appcompat.widget.AppCompatTextView {

    private final Context context;

    public BarTextView(Context context) {
        super(context);
        this.context= context;
        setTextSize();
        setGravity();
    }

    @Override
    public void setText(CharSequence text, BufferType type) {
        super.setText(text, type);
    }


    public void setTextColorWithBar(int barColor){
        if (TitleUtil.getRgb(barColor)){
            setTextColor(Color.BLACK);
        }else {
            setTextColor(Color.WHITE);
        }
    }

    public void setTextSize() {
        super.setTextSize(DpUtil.dp2sp(context, 19));
    }

    public void setGravity() {
        super.setGravity(Gravity.CENTER);
    }

    @Override
    public void setTextSize(float size) {
        super.setTextSize(size);
    }
}
